package kn.cstf2.assign.Server;

import kn.cstf2.global.Utils.CstF2Exception;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import kn.cstf2.assign.Bean.T_usersBean;
import kn.cstf2.transition.Bean.*;

/**
 * @author Izhar Gamaliel Hernandez Cruz Programador Java Junior Desarrollado para
 * Kuehne + Nagel
 */
public class AdaptadorAssign {

    
  public static ArrayList<T_usersBean>  obtenerListaNombresDataFromTusers(ResultSet rs) {
      ArrayList<T_usersBean> listaNombresTusers = new ArrayList<T_usersBean>();
        try {
            while (rs.next()) {
                T_usersBean t_usersBean = new T_usersBean(); 
                t_usersBean.setId(rs.getInt("id"));
                t_usersBean.setUsername(rs.getString("username"));
                t_usersBean.setPwd(rs.getString("pwd"));
                t_usersBean.setEmail(rs.getString("email"));
                t_usersBean.setUsertype(rs.getString("usertype"));
                
                listaNombresTusers.add(t_usersBean);
            }
               for(T_usersBean a : listaNombresTusers){
          System.out.println(a.getId()+" - "+a.getUsername()+a.getPwd()+" - "+a.getEmail()+" - "+a.getUsertype()+" - ");
            }
            
        } catch (SQLException ex) {
       
            throw new CstF2Exception("No se pudo obtener la informacion del Usuario");
        }
        return listaNombresTusers;
    }
  
  
  public static ArrayList<Integer>  obtenerKnkeys(ResultSet rs) {
        ArrayList<Integer> allknkeys = new ArrayList<Integer>();
        Integer knkey=null;
        try {
            while (rs.next()) {
                knkey=(rs.getInt("knkey"));
                allknkeys.add(knkey);
            }
        } catch (SQLException ex) {
     
            throw new CstF2Exception("No se pudo obtener la informacion del Usuario");
        }
        return allknkeys;
    }
  
  public static ArrayList<Integer>  obtenerCustomerNums(ResultSet rs) {
        ArrayList<Integer> allknkeys = new ArrayList<Integer>();
        Integer knkey=null;
        try {
            while (rs.next()) {
                knkey=(rs.getInt("customernum"));
                allknkeys.add(knkey);
            }
        } catch (SQLException ex) {
            
            throw new CstF2Exception("No se pudo obtener la informacion del Usuario");
        }
        return allknkeys;
    }

   
  public static T_usersBean  obtenerDateFromTusers(ResultSet rs) {
       T_usersBean t_usersBean = new T_usersBean(); 
      
        try {
            while (rs.next()) {
                t_usersBean.setId(rs.getInt("id"));
                t_usersBean.setUsername(rs.getString("username"));
                t_usersBean.setPwd(rs.getString("pwd"));
                t_usersBean.setEmail(rs.getString("email"));
                t_usersBean.setUsertype(rs.getString("usertype"));
                t_usersBean.setTran(rs.getBoolean("transition"));
                t_usersBean.setTranAccess(rs.getBoolean("transitionaccess"));
                t_usersBean.setImp(rs.getBoolean("implementation"));
                t_usersBean.setImpAccess(rs.getBoolean("implementationaccess"));
                t_usersBean.setCop(rs.getBoolean("cop"));
                t_usersBean.setCopAccess(rs.getBoolean("copaccess"));
                t_usersBean.setSu(rs.getBoolean("su"));
            }
        } catch (SQLException ex) {
         
            throw new CstF2Exception("No se pudo obtener la informacion del Usuario");
        }
        return t_usersBean;
    }

}
   